<?php
class Content extends Vfriend_Db {
	var $cache;
	var $clear;
	public function __construct() {
		$this->cache = new Vfriend_Cache();
		$this->clear = $this->cache->clear;
	}
	public function getByPage($strAction) {
		try {
			$strKey 	= CONTENT_GETBYPAGE . $strAction;
			$arrResult 	= $this->cache->get($strKey);
			if(!Vfriend_Function::isCached($arrResult)) {
				$this->prepare('call contents_get_page(?)');
				$this->bindParam(1, $strAction, PDO::PARAM_STR, 50);
				$arrResult = $this->fetchAll();				
				$this->cache->set($strKey, $arrResult, CONTENT_GETBYPAGE_EXPIRE);
			}		
			if($strAction == 'faq' || $strAction == 'question') {
				return isset($arrResult) ? $arrResult : null;
			} else {
				return isset($arrResult[0]) ? $arrResult[0] : null;
			}
		} catch(Exception $e) {
			Vfriend_Function::logDb('Content::getByPage - ' . $e->getMessage());
			return null;
		}
	}
}
?>